﻿using System;
using System.Collections.Generic;
using System.Linq;
using PermitsAndVisasLeadsSyncher.Data_Gateway;
using PermitsAndVisasLeadsSyncher.Model;
using PermitsAndVisasLeadsSyncher.Helpers.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace PermitsAndVisasLeadsSyncher.ApplicationFacade
{
    internal class Syncher
    {
        ILogger logger = LeadsSyncherLogger.CreateLogger();
        public void LeadSync()
        {
            LeadInfoGateway leadInfoGateway = new LeadInfoGateway();
            leadInfoGateway.LoadleadInfoFromService();
            string from = leadInfoGateway.getFromDate();
            string lastLeadDate = leadInfoGateway.getLastLeadDate();   
            logger.LogInfo("Start Date : " + from );
            logger .LogInfo ("End Date : " + lastLeadDate );
            List<Lead> leadlist = new List<Lead>();            
            LeadGateway leadGateway = new LeadGateway();
            leadlist = leadGateway.LeadLoadFromService(from, lastLeadDate);
            logger.LogInfo("Total Leads :" + leadlist.Count);
            leadGateway.LeadUpdation(leadlist);            
        }
    }
}
